package com.qd.common.panda.domain.entity.stroke;

import com.cdqidi.dict.annotation.FieldBind;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.qd.common.dict.DictConstant;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

/**
 * 商城订单
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class UserStrokeOrderMallDTO extends BaseQuery {

    /**
     * 主键(订单ID)
     */
    @NotBlank(message = "订单ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "订单ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String orderId;
    /**
     * 商品编码
     */
    @NotBlank(message = "商品编码不能为空", groups = DefaultGroup.class)
    @Size(max = 100, message = "商品编码长度不能超过{max}位", groups = DefaultGroup.class)
    private String commodityCode;
    /**
     * 商品名称
     */
    @NotBlank(message = "商品名称不能为空", groups = DefaultGroup.class)
    @Size(max = 100, message = "商品名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String commodityName;
    /**
     * 商品价格
     */
    private BigDecimal commodityPrice;
    /**
     * 结算价格
     */
    private BigDecimal discountPrice;
    /**
     * 商品简介
     */
    @Size(max = 200, message = "商品简介长度不能超过{max}位", groups = DefaultGroup.class)
    private String commodityIntroduction;
    /**
     * 商品图片
     */
    @Size(max = 200, message = "商品图片长度不能超过{max}位", groups = DefaultGroup.class)
    @FieldBind(targetField = "commodityPicDisplay",processName = DictConstant.SYS_FILE_CONFIRM)
    private String commodityPic;
    /**
     * 商品图片显示
     */
    private String commodityPicDisplay;
    /**
     * 商品数量
     */
    @NotNull(message = "商品数量不能为空", groups = DefaultGroup.class)
    private Long quantity;
    /**
     * 订单状态
     */
    @NotNull(message = "订单状态不能为空", groups = DefaultGroup.class)
    private Integer orderState;
    /**
     * 订单状态显示
     */
    private String orderStateDisplay;
    /**
     * 行程ID
     */
    @NotBlank(message = "行程ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "行程ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String sid;
    /**
     * 商品ID
     */
    @NotBlank(message = "商品ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "商品ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String commodityId;
    /**
     * 充值账号
     */
    @Size(max = 50, message = "充值账号长度不能超过{max}位", groups = DefaultGroup.class)
    private String rechargeAccount;
    /**
     * 产品形式
     */
    @Size(max = 50, message = "产品形式长度不能超过{max}位", groups = DefaultGroup.class)
    @FieldBind(targetField = "productFormDisplay")
    private String productForm;
    /**
     * 产品形式显示
     */
    private String productFormDisplay;
    /**
     * 是否重试
     */
    @FieldBind(targetField = "retryDisplay")
    private String retry;
    /**
     * 是否重试显示
     */
    private String retryDisplay;
    /**
     * 卡密信息
     */
    private List<UserStrokeOrderMallCardInfoDTO> cardInfoList;

    @Override
    public void freeData() {
        this.commodityCode = null;
        this.commodityName = null;
        this.commodityPrice = null;
        this.discountPrice = null;
        this.commodityIntroduction = null;
        this.commodityPic = null;
        this.quantity = null;
        this.orderState = null;
        this.orderStateDisplay = null;
        this.orderId = null;
        this.sid = null;
        this.commodityId = null;
        this.rechargeAccount = null;
        this.productForm = null;
        this.productFormDisplay = null;
        this.retry = null;
        this.retryDisplay = null;
        Optional.ofNullable(cardInfoList).ifPresent(List::clear);
        super.freeData();
    }
}
